package com.imc.core.utils;

import com.imc.platform.base.menu.pojo.Menu;
import com.imc.platform.base.user.pojo.User;
import com.imc.platform.frame.mapper.ICommonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Component
public class MenuUtils {

    @Autowired
    ICommonMapper commonMapper;

    public List<Menu>getMenuByRoleId(HttpServletRequest request,String menuId){
        HttpSession session = request.getSession();
        User user=(User) session.getAttribute("currentUser");
        List<Menu> menu=commonMapper.queryMenuByRoleIdAndMenuId(user.getRoleId(),menuId);
        return menu;
    }

    public String getMealUrlByParentId(String parentId){
        return commonMapper.queryMealUrlByParentId(parentId)+"?menuId="+parentId;
    }
}
